package cn.tedu.web.lsw.servlet;


import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import sun.plugin.dom.core.Element;

import javax.jnlp.FileContents;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(urlPatterns = "/pp")
public class CaptchaServlet extends HttpServlet {
   @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
       HttpSession session=req.getSession();
       LineCaptcha captcha = CaptchaUtil.createLineCaptcha(200, 50);
       String pp=captcha.getCode();
       session.setAttribute("c",pp);

       try {
           captcha.write(resp.getOutputStream());
       } catch (IOException e) {
           e.printStackTrace();
       }
   }
}
